package com.sbtr.controller.classify;

import com.sbtr.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.sbtr.common.PageDto;
import com.sbtr.business.classify.entity.AlgoCorpgenerate;
import com.sbtr.business.classify.dto.AlgoCorpgenerateDto;
import com.sbtr.business.classify.service.AlgoCorpgenerateService;
import org.springframework.web.bind.annotation.RestController;
import com.sbtr.controller.common.CommonController;

/**
 * 算法生成 前端控制器
 *
 * @author dgl
 * @since 2023-09-08
 */
@RestController
@RequestMapping("/algoCorpgenerate")
@Api(tags = "算法裁剪生成")
public class AlgoCorpgenerateController extends CommonController<AlgoCorpgenerate,AlgoCorpgenerateService> {

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<AlgoCorpgenerate>> pageList(AlgoCorpgenerateDto algoCorpgenerateDto){
        return Response.success(u.pageList(algoCorpgenerateDto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "保存")
    public Response<AlgoCorpgenerate> save(@RequestBody AlgoCorpgenerate algoCorpgenerate){
        algoCorpgenerate.setId(null);
        if(algoCorpgenerate.insert()){
            return Response.success(algoCorpgenerate);
        }else throw new BDException("保存失败");
    }

}

